jQuery(document).ready(function(){		
	jQuery('.paginate_button').click(function(){				
		showAjaxEffect();				
	});	
	//bump category in grid list
	jQuery('.imagelist .btn_flag').click(function(){		
		var parent = jQuery(this).parents('li');
		var title = jQuery(this).attr("rel");
		var c = confirm('Playlist \"' + title + '\" will be the first one in home page ?');
		if(c) {
			showAjaxEffect();	
			var id = jQuery(this).attr("href");			
			jQuery.get("/admin/playlist/process", {id: id, action: "bump"}, function(data) {	
				var currentLi = jQuery("ul > li#" + id);	
				hideAjaxEffect();					
				jQuery('#table-result tbody tr td input[type=checkbox]').each(function (item, data) {
					if (jQuery(this).is(':checked')) {				
						jQuery(this).parents("tr").remove();						
					}
				});
				jQuery('#messageDiv').fadeIn();
				jQuery('#messageDiv').addClass('msgsuccess').removeClass('hidden');
				jQuery('#messageDiv > p').html('Action success !');
				setTimeout(function() {
					jQuery('#messageDiv').fadeOut();
				}, 2000);
				var currentPage = jQuery('.paginate_active').text();				
				if(currentPage===''||currentPage==='1'){
					currentLi.parent("ul").prepend(currentLi);					
				}else{
					currentLi.remove();					
				}				
				scrollToTop();				
			});					
		}
		return false;
	});
	//delete image in grid list
	jQuery('.imagelist .btn_trash').click(function(){
		var parent = jQuery(this).parents('li');
		var title = jQuery(this).attr("rel");
		var c = confirm('Are you sure want to delete \"' + title + '\" playlist ?');
		if(c) {
			var id = jQuery(this).attr("href");			
			jQuery.get("/admin/playlist/process", {id: id, action: "delete"}, function(data) {				
				parent.hide('explode',300);
			});					
		}
		return false;
	});	
});

